package com.peng.leetcode.search;

/**
 * FindPeakElement1
 * 162. 寻找峰值
 * https://leetcode.cn/problems/find-peak-element/
 *
 * @author: lupeng6
 * @create: 2023/2/21 13:38
 */
public class FindPeakElement1 {
    public int findPeakElement(int[] nums) {
        int l = 0;
        int r = nums.length - 1;
        while (l < r) {
            int mid = l + (r - l) / 2;
            if (nums[mid] < nums[mid + 1]) {
                l = mid + 1;
            } else {
                r = mid;
            }
        }
        return l;
    }
}
